package com.syg.servlet10_buffered;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 将不经常变化的数据,缓存到客户端,避免浏览器频繁向服务器发送请求(这个例子不管用)
 */
@WebServlet("/buffered")
public class _01_Buffered extends HttpServlet{
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String str = "将不经常变化的数据,缓存到客户端,避免浏览器频繁向服务器发送请求";
        resp.setDateHeader("expires",System.currentTimeMillis()+24*60*60*1000);
        resp.getWriter().write(str);
    }
}
